from zhi_dao.entity.zhidao_section import ZhiDaoSection
from zhi_dao import driver_action
import time


class ZhiDaoSectionSelector:
    sections: list[ZhiDaoSection]
    current_section: int

    def __init__(self, sections: list[ZhiDaoSection]):
        self.sections = sections

    def select_section(self, index):
        if self.sections is None or len(self.sections) == 0 or len(self.sections) < index:
            return
        selected_element = self.sections[index]
        driver_action.click(selected_element.get_element()).perform()
        self.current_section = index
        time.sleep(5)

    def select_next_section(self):
        self.select_section(self.current_section + 1)



